//
//  HotCateModel.swift
//  swiftDemo
//
//  Created by Gerry on 2021/11/21.
//

import UIKit

@objcMembers
class HotCateModel : NSObject {
    
    var icon_url : String?
    var small_icon_url : String?
    var tag_name : String?
    var tag_id : Int?
    var room_list : [RoomItem]? = [RoomItem]()
//    {
//        didSet {
//            guard let arr = room_list as? [[String : NSObject]] else {
//                return
//            }
//            for dict in arr {
//                let roomItem = RoomItem.init(dict)
//                rooms.append(roomItem)
//            }
//        }
//    }
    lazy var rooms : [RoomItem] = [RoomItem]()
    
    override init() {
        super.init()
    }
    init(_ dict : [String : NSObject]) {
        super.init()
        
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forKey key: String) {
        if key == "room_list" {
            if let arr = value as? [[String : NSObject]] {
                for item in arr {
                    room_list?.append(RoomItem(item))
                }
            }
        } else {
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    /**
      @brief  yy_model嵌套解析对象
     */
    static func modelContainerPropertyGenericClass() -> [String : Any]? {
            return ["room_list": RoomItem.classForCoder()]
    }
}
